#include "QtMoveToEffect.h"
#include "QtSprite.h"

QtMoveToEffect::QtMoveToEffect(): target(0)
{
}

QtMoveToEffect::~QtMoveToEffect()
{
}

QtMoveToEffect::QtMoveToEffect(const QtMoveToEffect& rhs): QtSingleAnimationEffect(rhs), target(rhs.target), endPosition(rhs.endPosition), startPosition(rhs.startPosition)
{

}


void QtMoveToEffect::SetTarget(QtSprite *sprite)
{
	target = sprite;
}

QtSprite* QtMoveToEffect::Target() const
{
	return target;
}

void QtMoveToEffect::Update(qreal value)
{
	if (target)
	{	
		target->SetPosition( startPosition + (endPosition-startPosition)*value );
	}
}

void QtMoveToEffect::SetEndPosition(const QPointF& position)
{
	endPosition = position;
}

void QtMoveToEffect::SetupAnimation()
{
	startPosition = target->Position();
}

QtAnimationEffect* QtMoveToEffect::Clone() const
{
	return new QtMoveToEffect(*this);
}

